import 'package:ati_package/core/extension/ati_widgets_extension.dart';
import 'package:ati_package/core/utils/ati_assets.dart';
import 'package:ati_package/core/utils/ati_enum.dart';
import 'package:ati_package/core/utils/ati_font.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../../core/routes/app_routes.dart';
import '../../../common/ati_scaffold.dart';

class UserAboutusView extends StatefulWidget {
  const UserAboutusView({super.key});

  @override
  State<UserAboutusView> createState() => _UserAboutusViewState();
}

class _UserAboutusViewState extends State<UserAboutusView> {
  @override
  Widget build(BuildContext context) {
    return AtiScaffold(
      title: '关于我们',
      body: ListView(
        children: [
          _buildHeaderWidget(),
          _buildItem(UserCenterModel.userAboutUsyhxy, '用户协议'),
          _buildItem(UserCenterModel.userAboutUsysxy, '隐私协议'),
          _buildItem(UserCenterModel.userAboutUsbbgx, '检查版本更新'),
        ],
      ),
    );
  }

  _buildHeaderWidget() {
    return Container(
      margin: EdgeInsets.only(left: 16.r, top: 10.r, right: 16.r),
      padding: EdgeInsets.only(top: 20.r, bottom: 15.r),

      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8.r),
      ),
      child: Column(
        children: [
          Image.asset(
            width: 60.r,
            height: 60.r,
            AtiAssets.trendCommentIcon,
            package: 'ati_package',
          ),
          SizedBox(height: 20.r),
          Text(
            'ATI',
            style: TextStyle(
              fontSize: AtiFont.font18,
              fontWeight: FontWeight.w600,
            ),
          ),
          SizedBox(height: 7.5.r),
          Text('1.3.2', style: TextStyle(fontSize: AtiFont.font14)),
        ],
      ),
    );
  }

  _buildItem(UserCenterModel centerModel, String titleStr) {
    return Container(
      height: 46.r,
      margin: EdgeInsets.only(left: 16.r, top: 10.r, right: 16.r),
      padding: EdgeInsets.symmetric(horizontal: 16.r),

      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8.r),
      ),
      child: Row(
        children: [
          Text(titleStr, style: TextStyle(fontSize: AtiFont.font14)),
          Spacer(),
          ...[
            if (centerModel == UserCenterModel.userAboutUsbbgx)
              Text('1.3.2', style: TextStyle(fontSize: AtiFont.font14)),

            SizedBox(width: 2.r),
            Image.asset(
              width: 14.r,
              height: 14.r,
              AtiAssets.atiNextIcon,
              package: 'ati_package',
            ),
          ],
        ],
      ),
    ).addTapGesture(
      onTap: () {
        switch (centerModel) {
          case UserCenterModel.userAboutUsyhxy:
            {
              Get.toNamed(
                AtiAppRoutes.atiWebShow,
                arguments: {
                  'url':
                      'https://pub-web.flutter-io.cn/packages/screenshotx/versions',
                  'title': '用户协议',
                },
              );
            }
            break;
          case UserCenterModel.userAboutUsysxy:
            {
              Get.toNamed(
                AtiAppRoutes.atiWebShow,
                arguments: {
                  'url':
                      'https://pub-web.flutter-io.cn/packages/screenshotx/versions',
                  'title': '隐私协议',
                },
              );
            }
            break;
          case UserCenterModel.userAboutUsbbgx:
            {}
            break;
          default:
            {}
            break;
        }
      },
    );
  }
}
